

package service;

import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService()
public class WSCaculator {

    @WebMethod(operationName = "add")
    public int add(@WebParam(name = "a") int a, @WebParam(name = "b") int b) {
        return a + b;
    }

    @WebMethod(operationName = "time")
    public String getTime() {
        Date time = new Date();
        String txt = time.toString();
        return txt;
    }

    @WebMethod(operationName = "validateCard")
    public boolean validate(@WebParam(name = "cartId") String CardId) {
        Pattern pattern = Pattern.compile("^[a-zA-Z]\\d{8}[a-zA-Z]$");
        Matcher matcher = pattern.matcher(CardId);
        if (matcher.find()) {
            return true;
        }
        return false;
    }
}

